﻿@model TamoCRM.Web.Mvc.Areas.Admin.Models.Contacts.ContactAddModel
@{
    ViewBag.Title = "Tạo Contact Hotline";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
@{
    var consultantNomrs = ViewBag.ConsultantNomrs;
    var sourceTypeMaps = ViewBag.SourceTypeMaps;
    var genders = ViewBag.Genders;
    var schools = ViewBag.Schools;

    var lstConsultantNomrs = new SelectList(consultantNomrs, "ConsultantId", "FullName");
    var lstSourceTypeMaps = new SelectList(sourceTypeMaps, "Id", "Name");
    var lstSchools = new SelectList(schools, "SchoolId", "Name");
    var lstGenders = new SelectList(genders, "Code", "Name");
}
<div class="breadcrumbs" id="breadcrumbs">
    <script type="text/javascript">
        try {
            ace.settings.check('breadcrumbs', 'fixed');
        } catch (e) {
        }
    </script>

    <ul class="breadcrumb">
        <li>
            <i class="icon-home home-icon"></i>
            <a href="/Home">Trang chủ</a>
        </li>

        <li>
            <a href="javascript:void(0);">Danh mục</a>
        </li>
        <li class="active">Contact</li>
    </ul>
</div>
<div class="page-content">
    <div class="page-header">
        <h1>Thêm mới contact hotline								
        </h1>
    </div>
    <!-- /.page-header -->

    <div class="row">
        <div class="col-xs-12">
            @using (Html.BeginForm("CreateHotline", "Contact", FormMethod.Post))
            {
                @Html.AntiForgeryToken()
                <div class="form-group">
                    <div class="col-sm-12" id="alert">
                    </div>
                </div>
                <div style="border: 1px solid #c5d0dc; padding: 25px;">
                    <div class="row">
                        <div class="col-xs-2">
                            Họ và tên*
                        </div>
                        <div class="col-xs-4">
                            <div class="clearfix">
                                @Html.TextBoxFor(x => x.ContactInfo.Fullname, new { @style = "width: 90%", @required = "required", error = "Họ và tên rỗng" })
                            </div>
                        </div>
                        <div class="col-xs-2">
                            Loại*
                        </div>
                        <div class="col-xs-4">
                            <div class="clearfix">
                                @Html.DropDownListFor(x => x.SourceTypeMapId, lstSourceTypeMaps, new { @class = "form-control", @required = "required", error = "Loại rỗng" })
                            </div>
                        </div>
                    </div>
                    <div class="space-4"></div>
                    <div class="row">
                        <div class="col-xs-2">
                            Số điện thoại 1*
                        </div>
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">
                                    <i class="icon-phone"></i>
                                </span>@Html.TextBoxFor(x => x.Mobile1, new { @style = "width: 88.5%", @required = "", @pattern = "^(?!0)((\\d{3}-\\d{3}-\\d{4,5})|\\d{9,10})$", error = "Số điện thoại rỗng hoặc không đúng định dạng" })
                            </div>
                        </div>
                        <div class="col-xs-2">
                            Số điện thoại 2
                        </div>
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">
                                    <i class="icon-phone"></i>
                                </span>@Html.TextBoxFor(x => x.Mobile2, new { @style = "width: 100%", @pattern = "^(?!0)((\\d{3}-\\d{3}-\\d{4,5})|\\d{9,10})$", error = "Số điện thoại không đúng định dạng" })
                            </div>
                        </div>
                    </div>
                    <div class="space-4"></div>
                    <div class="row">
                        <div class="col-xs-2">
                            Email 1*
                        </div>
                        <div class="col-xs-4">
                             <div class="input-group">
                                <span class="input-group-addon">
                                    <i class="icon-envelope" style="width: 11px;"></i>
                                </span>
                                @Html.TextBoxFor(x => x.Email1, new { style = "width: 88.5%", @pattern = ".*?@.*?", error = "Email rỗng hoặc không đúng định dạng" })
                            </div>
                        </div>
                        <div class="col-xs-2">
                            Email 2
                        </div>
                        <div class="col-xs-4">
                             <div class="input-group">
                                <span class="input-group-addon">
                                    <i class="icon-envelope" style="width: 11px;"></i>
                                </span>
                                @Html.TextBoxFor(x => x.Email2, new { @style = "width: 100%", @pattern = ".*?@.*?", error = "Email không đúng định dạng" })
                            </div>
                        </div>
                    </div>
                    <div class="space-4"></div>
                    <div class="row">
                        <div class="col-xs-2">
                            Giới tính  
                        </div>
                        <div class="col-xs-4">
                            @Html.DropDownListFor(x => x.ContactInfo.Gender, lstGenders, new { @class = "form-control", style = "width: 90%" })
                        </div>
                        <div class="col-xs-2">
                            Ngày sinh
                        </div>
                        <div class="col-xs-4">@Html.EditorFor(x => x.Birthday, new { @class = "form-control", @style = "width: 100%", @pattern = "\\d{2}/\\d{2}/\\d{4})", error = "Ngày sinh không đúng định dạng" })
                        </div>
                    </div>
                    <div class="space-4"></div>
                    <div class="row">
                        <div class="col-xs-2">
                            Trường học
                        </div>
                        <div class="col-xs-4">
                            @Html.DropDownListFor(x => x.ContactInfo.SchoolId, lstSchools, new { @class = "form-control", style = "width: 90%" })
                        </div>
                        <div class="col-xs-2">
                            TVTS
                        </div>
                        <div class="col-xs-4">@Html.DropDownListFor(x => x.ContactInfo.UserId, lstConsultantNomrs, new { @class = "form-control", @style = "width: 100%", @pattern = "\\d{2}/\\d{2}/\\d{4})", error = "Ngày sinh không đúng định dạng" })
                        </div>
                    </div>
                    <div class="space-4"></div>
                    <div class="row">
                        <div class="col-xs-2">
                            Ghi chú
                        </div>
                        <div class="col-xs-10">
                            @Html.TextAreaFor(x => x.ContactInfo.Notes, new { @class = "autosize-transition form-control" })
                        </div>
                    </div>
                </div>
                <div class="space-6"></div>
                <button id="btnSubmit" class="btn-primary" style="float: right;">Thêm mới Contact</button>
                <div class="clearfix"></div>
                <script>
                    $('#Birthday').datepicker({ format: 'dd/mm/yyyy', autoclose: true, dateonly: true, endDate: "+0d" });
                </script>
            }
        </div>
    </div>
</div>
<script src="/Content/themes/ace/assets/js/jquery.form.js"></script>
<script src="/Content/themes/ace/assets/js/jquery.validate.min.js"></script>
<script src="/Content/themes/ace/assets/js/jquery.maskedinput.min.js"></script>
<script src="/Content/themes/ace/assets/js/additional-methods.min.js"></script>


<script type="text/javascript">
    $(document).ready(function () {        
        customValidate();
    });
    
    var message = '@ViewBag.Message';
    if (message == null || message == '') {
        $("#alert").removeClass();
        $("#alert").html('');
    }
    else {
        $("#alert").addClass("alert alert-block alert-success");
        $("#alert").html(message);
    }
</script>
